package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/3/1 11:49
 * @description
 */
public class Code376 {
    public static void main(String[] args) {
        new Code376().wiggleMaxLength(new int[] {1, 17, 5, 10, 13, 15, 10, 5, 16, 8});
    }

    public int wiggleMaxLength(int[] nums) {
        int n = nums.length;
        if (n < 2) {
            return n;
        }
        int up = 1;
        int down = 1;
        for (int i = 1; i < n; i++) {
            if (nums[i] > nums[i - 1]) {
                up = down + 1;
            }
            if (nums[i] < nums[i - 1]) {
                down = up + 1;
            }
        }
        return Math.max(up, down);
    }
}
